package com.xiaodu.acer.phoneplay.data.dao;

import com.xiaodu.acer.phoneplay.App;
import com.xiaodu.acer.phoneplay.bean.SearchHistoryBean;

import java.util.List;

/**
 * Created by handsome on 2016/4/19.
 */
public class SearchHistoryDao {

    /**
     * 添加数据
     */
    public static void insert(SearchHistoryBean bean) {
        App.getDaoInstant().getSearchHistoryBeanDao().insert(bean);
    }

    /**
     * 删除指定数据
     *
     * @param id
     *//*
    public static void delete(long id) {
        App.getDaoInstant().getSearchHistoryBeanDao().deleteByKey(id);
    }*/


    /**
     * 删除全部数据
     */
    public static void deleteAll() {
        App.getDaoInstant()
                .getSearchHistoryBeanDao()
                .deleteAll();
    }

    /**
     * 更新数据
     */
    public static void update(SearchHistoryBean bean) {
        App.getDaoInstant()
                .getSearchHistoryBeanDao()
                .update(bean);
    }

    /**
     * 查询全部数据并倒序展示
     *
     * @return
     */
    public static List<SearchHistoryBean> query() {
        return App.getDaoInstant()
                .getSearchHistoryBeanDao()
                .queryBuilder()
                .orderDesc()
                .list();
    }

}
